package com.itheima.homework;

import java.util.Scanner;

/**
 * 案例1 买飞机票
 */
public class Homework01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入机票价格：");
        double Price = sc.nextDouble();
        System.out.println("请输入月份：");
        int month = sc.nextInt();
        System.out.println("请输入舱位类型：");
        String type = sc.next();
        System.out.println("最终价格：" + buyTicket(Price, month, type));

    }

    //机票原价 当前月份 舱位类型 变量来接收
    public static double buyTicket(double price, int month, String type) {
        if (month >= 5 && month <= 10) {//旺季
            //switch 判断头等舱还是经济舱
            switch (type) {
                case "头等舱":
                    price *= 0.9;
                    break;
                case "经济舱":
                    price *= 0.85;
                    break;
            }
        } else if (month >= 0 && month < 5 || month > 10 && month <= 12) {//淡季
            //switch判断头等舱或者经济舱
            switch (type) {
                case "头等舱":
                    price *= 0.7;
                    break;
                case "经济舱":
                    price *= 0.65;
                    break;
            }

        }
        return price;//返回优惠后的价格
    }
}
